package com.pfdu.simplescheduler.node;

import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

public class HeartBeatDelay implements Delayed {

    /**
     * 到期时间 = 当前时间+延迟时间
     */
    private long expire;

    public HeartBeatDelay(long delay) {
        this.expire = System.currentTimeMillis() + (delay * 1000);
    }

    @Override
    public long getDelay(TimeUnit unit) {
        return unit.convert(this.expire - System.currentTimeMillis(), TimeUnit.MILLISECONDS);
    }

    @Override
    public int compareTo(Delayed o) {
        return 0;
    }
}
